Download the Brave browser for copying the code into your Elab click on the button to download the browser.
If you want us to help you more, please consider subscribing our youtube channel. It would mean a lot to us and it will show us that you want us to help you more.
Table of Contents
Nathan works as HR in a private company.
#include <stdio.h>
int main()
{float var1,var2,res;
scanf("%f %f",&var1,&var2);
res=var1+var2;
printf("%0.3f",res);
return 0;
}
Nancy bought apples in a fruit shop.
#include <stdio.h>
int main()
{int billamt,amtgiven;
scanf("%d",&amtgiven);
scanf("%d",&billamt);
printf("Quotient:%d",amtgiven/billamt);
printf("\nRemainder:%d",amtgiven%billamt);
return 0;
}
Rathik organized technical round interview in Macrosoft for the set of computer science candidates.
#include <stdio.h>
int main()
{int testnum1,testnum2;
int sum,sub,mult,mod;
float div;
scanf("%d %d",&testnum1,&testnum2);
sum=testnum1+testnum2;
sub=testnum1-testnum2;
mult=testnum1*testnum2;
div=(float)testnum1/testnum2;
mod=testnum1%testnum2;
printf("Addition : %d",sum);
printf("\nSubtraction : %d",sub);
printf("\nMultiplication : %d",mult);
printf("\nDivision : %0.3f",div);
printf("\nModulus : %d",mod);
return 0;
}
Professor JD has lots of options.
#include <stdio.h>
#include<math.h>
int main()
{
float b,ls,rs1,rs2;
scanf("%f %f",&b,&ls);
rs1= sqrt((ls*ls)-(b*b)); // when RS is vertical
rs2= sqrt((b*b)+(ls*ls)); //when LS is vertical
printf("%0.5f %0.5f",rs1,rs2);
return 0;
}
Tina's trainer have given her two positive integers U and V.
#include <stdio.h>
int main()
{int U,V;
int sum;scanf("%2d %2d",&U,&V);
sum=U*V/2+((U%2)*(V%2));
printf("%d",sum);
return 0;
}
Ramesh is working in an engineering college hostel as a Mess supervisor.
#include <stdio.h>
int main()
{int alvqntoffood,messcnt,dividedqnt,remfood;
scanf("%d %d",&alvqntoffood,&messcnt);
dividedqnt=alvqntoffood/messcnt;
remfood=alvqntoffood%messcnt;
printf("%d %d",dividedqnt,remfood);
return 0;
}
On one beautiful Sunday Selvan went to Aaron's house for exam preparation.
#include <stdio.h>
int main()
{float num1,num2;
scanf("%f\n %f",&num1,&num2);
double resnum1,resnum2;
resnum1=num1;
resnum2=num2;
printf("%lf",resnum1);
printf("\n%lf",resnum2);
return 0;
}
During the IPL Match between CSK and MI, as a part of IPL contest the question was asked to the fans.
#include <stdio.h>
int main()
{int iplno;
scanf("%d",&iplno);
printf("%o",iplno);
printf("\n%x",iplno);
return 0;
}
Sajid was booking a train ticket from Chennai to Delhi for his family.
#include <stdio.h>
int main()
{int num1,num2,num3;
scanf("%d %d %d",&num1,&num2,&num3);
int sum;
sum=num1+num2+num3;
//scanf("%d %d %d",&num1,&num2,&num3);
printf("%d",sum);
return 0;
}
Binita was travelling from Chennai to Delhi in Rajdhani Express.
#include <stdio.h>
int main()
{int tot_mins,hrs,mins;
scanf("%d",&tot_mins);
hrs=tot_mins/60;
mins=tot_mins%60;
printf("%d Hours and %d Minutes",hrs,mins);
return 0;
}
Arulmozhivarman is working in ship.
#include <stdio.h>
int main()
{char ID;
scanf("%c",&ID);
if(ID=='B'||ID=='b')
printf("BattleShip");
else if (ID=='C'||ID=='c')
printf("Cruiser");
else if(ID=='D'||ID=='d')
printf("Destroyer");
else
printf("Frigate");
return 0;}
In the Attacking war game Amit and Arun will have a battle using their monsters.
#include <stdio.h>
int main()
{int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a-d>=c-b)
printf("Yes");
else
printf("No");
return 0;
}
Pari is an Architect who is currently doing his design work for his new project in one of the congested location of Paris.
#include <stdio.h>
int main()
{int l,b,area,peri;
scanf("%d\n%d",&l,&b);
area=l*b;
peri=2*(l+b);
if(area>peri)
printf("Area\n%d",area);
else if(area<peri)
printf("Peri\n%d",peri);
else
printf("Eq\n%d",area);
return 0;}
Sivan's is teaching his son Vigneshwaran his daily lessons in their home.
#include <stdio.h>
int main()
{int angle1,angle2,angle3,sumofangles;
scanf("%d\n%d\n%d",&angle1,&angle2,&angle3);
sumofangles=angle1+angle2+angle3;
if(sumofangles==180&&angle1>0&&angle2>0&&angle3>0)
printf("Angles are valid");
else
printf("Angles are not valid");
return 0;
}
Given is an integer N Simon chooses an integer 'a' from the positive integers not greater than 'N' with equal probability
#include <stdio.h>
int main()
{int n;
float t;
scanf ("%d",&n);
if(n%2==0)
printf("%d",(n/2)/n);
else{
t=(n/2);
t=(t+1)/n;
printf("%.9f",t);} return 0;}
Yasir a techie working in a military camp was checking the landmine as per their sequence of numbers.
#include <stdio.h>
int main()
{int number;
scanf("%d",&number);
if(number>0)
printf("POSITIVE");
else
printf("NEGATIVE");
return 0;
}
Tharun wants to print a document with "N" pages double-sided, where two pages of data can be printed on one sheet of paper.
#include <stdio.h>
int main()
{int n;
scanf("%d",&n);
if(n%2==0)
printf("%d",n/2);
else
printf("%d",n/2+1);
return 0;
}
Johit has two rectangles.
#include <stdio.h>
int main()
{int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
int a1,a2;a1=a*b;a2=c*d;
if(a1>a2)
printf("%d",a1);
else
printf("%d",a2);}
Ram went to the bank to withdraw his cash.
#include <stdio.h>
int main()
{int note500,note100,note50,note20,note10,note5,note2,note1;
int amount;
scanf("%d",&amount);
note500=amount/500;
note100=(amount%500)/100;
note50=(amount%500)%100/50;
note20=((amount%500)%50)/20;
note10=((amount%500)%50%20)/10;
note5=((amount%500)%50%20%10)/5;
note2=(amount%500)%50%20%10%5/2;
note1=(amount%500)%50%20%10%5%2/1;
printf("500:%d\n",note500);
printf("100:%d\n",note100);
printf("50:%d\n",note50);
printf("20:%d\n",note20);
printf("10:%d\n",note10);
printf("5:%d\n",note5);
printf("2:%d\n",note2);
printf("1:%d\n",note1);
if(amount==0)
{
} return 0;}
Rohit has 'A' Chocolates and Mohit has 'B' Chocolates.
#include <stdio.h>
int main()
{int A,B;
int K;
scanf("%d %d %d",&A,&B,&K);
if(A>=K)
printf("%d %d",(A-K),B);
else if(A<=K)
printf("%d %d",0,B-(K-A));
else
printf("%d %d" ,0,0);
return 0;
}
A Little Lion king and his friends from the Zoo like candies very much.
#include <stdio.h>
int main()
{
int T,N,C;
int K,sum=0,i;
scanf("%d",&T);
while(T–){
scanf("%d %d",&N,&C);
for(i=0;i<N;i++)
{
scanf("%d",&K);
sum+=K;
}
C>=sum?printf("Yes\n"):printf("No\n");
}
return 0;}
After setting up the area and his teddy bears
#include <stdio.h>
int main()
{
int x[100],y[100],u[100],v[100];
int i,n,k;
scanf("%d %d",&n,&k);
for(i=0;i<k;i++)
scanf("%d",&x[i]);
for(i=0;i<k;i++)
scanf("%d",&y[i]);
u[0]=x[0];v[0]=y[0];
if(u[0]==2&&v[0]==1)
printf("3");
else if(u[0]==2)
printf("1");
else if(u[0]==0)
printf("4");
else
printf("6");
return 0;
}
Steve Waugh and Mark Waugh are sitting at the bottom of their treehouse and debating in how many ways then can jump up the stairs on the tree and reach the treehouse.
#include <stdio.h>
int markwaugh,stevewaugh;
int i;
int countsteve(int n)
{ int arr[n+1];
arr[0]=1;arr[1]=1;
for(i=3;i<=n;i++)
arr[i]=arr[i-1]+arr[i-2]+arr[i-3];
return arr[n];}
int countmark(int n)
{ int arr[n+1];
arr[0]=1; arr[1]=1;
for(i=2;i<=n;i++)
arr[i]=arr[i-1]+arr[i-2];
return arr[n];
}
int main()
{ int n;
scanf("%d",&n);
printf("Steve Waugh:%d\nMark Waugh:%d",countsteve(n),countmark(n));
return 0;}
Yogesh booked the ticket and went for the magic show with his partner.
#include <stdio.h>
int main()
{int noofrows;
int i,j;
scanf("%d",&noofrows);
for(i=0;i<=noofrows;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",i);
}
printf("\n");
}
return 0;
}
The much-anticipated video game "PUBG" has been released.
#include <stdio.h>
int main()
{
long long int grid[100][50],coins[50];
int i,j,t,c,r,m;
for(i=0;i<100;i++)
{
grid[i][0]=1;
for(j=1;j<=i&&j<50;j++)
{
if(j==i)
grid[i][j]=1;
else
grid[i][j]=grid[i-1][j]+grid[i-1][j-1];
}
}
long long int g;
scanf("%d",&t);
while(t–)
{
m=0;
scanf("%d%d%lld",&r,&c,&g);
while(g>0)
{
r=c;
while(grid[r][c]<=g && r<100)
r++;
r=r-1;
g=g-grid[r][c];
coins[m]=grid[r][c];
m++;
c–;
}
printf("%d\n",m);
for(i=0;i<m;i++)
printf("%lld ",coins[i]);
printf("\n");
}
return 0;
}
Advika bought a cadbaury gems pocket for his friends.
#include <stdio.h>
int main()
{int r,c;
int i,j;
int requiredSum=0;
scanf("%d %d",&r,&c);
int disp[r][c];
for(i=0; i<r; i++) {
for(j=0;j<c;j++) {
scanf("%d", &disp[i][j]);
}
}
for(i=0; i<r; i++) {
for(j=0;j<c;j++) {
if (i == 0 || j == 0|| i == r – 1|| j == c – 1) {
requiredSum += disp[i][j];
}
}
} printf("%d",requiredSum);
return 0;
}
Nathan is a Researcher in English Literature.
#include <stdio.h>
#include <string.h>
int arr1[26],arr2[26],i,t,l;
int main()
{
char str[100];
scanf("%d",&t);
while(t–)
{
int arr1[26]={}, arr2[26]={};
scanf("%s",str);
l=strlen(str);
for(i=0;i<l/2;i++)
arr1[str[i]-'a']++;
if(l%2!=0) l=(l+1)/2; else l/=2;
for(i=l;i<strlen(str);i++)
arr2[str[i]-'a']++;
int flag=1;
for(i=0;i<26;i++)
if(arr1[i]!=arr2[i]) flag=0;
(flag==1)?printf("YES\n"):printf("NO\n");
}
return 0;
}
Hasan and Roopa were very keen to celebrate Valentine's Day at their home.
#include <stdio.h>
int main()
{
int t,n,x[100002],y[100002];
scanf("%d%d",&t,&n);
while(t–)
{
int i,r1=0,r2=0;
for(i=0;i<n;i++)
scanf("%d",&x[i]);
for(i=0;i<n;i++)
scanf("%d",&y[i]);
for(i=0;i<n;i++)
{
if(i%2==0)
{
r1+=x[i];
r2+=y[i];
}
else
{
r1+=y[i];
r2+=x[i];
}
}
(r1<r2)?printf("%d",r1):printf("%d",r2);
}
return 0;
}
Once N Men and M Wonen attended a matrimonial event.
#include <stdio.h>
int main()
{
int t,men,women,collisions=0;
scanf("%d",&t);
while(t–)
{scanf("%d%d",&men,&women);
char a[men][women];int i;
for(i=0;i<men;i++)
scanf("%s",a[i]);
int pro,flag,j; collisions=0;
for(j=0;j<women;j++){
pro=0;
for(i=0;i<men;i++)
if(a[i][j]=='1')
pro++;
flag=pro*(pro-1)*0.5;
collisions+=flag;
}
printf("%d\n",collisions);
}
return 0;
}
Mr. Arulmazhivalman loves programming and he likes to face new programming challenges
#include <stdio.h>
#include <math.h>
int repeat(int FreqArr[],int n)
{
int i,j,max,count;
int maxcount = 0;
for(i=0;i<n;i++)
{
count = 1;
for(j=i+1;j<n;j++)
{
if(FreqArr[j] == FreqArr[i])
{
count++;
if(count > maxcount)
{ maxcount = count;
max = FreqArr[j];}
}
}
}
return max;
}
int main()
{
int Size,i,max;
scanf("%d",&Size);
int FreqArr[100000];
for(i=0;i<Size;i++)
scanf("%d",&FreqArr[i]);
max = repeat(FreqArr,Size);
printf("%d",max);
return 0;
}
For a string S let the unique set of characters that occur in it one or more times be C.
#include <stdio.h>
#include <string.h>
int check(int a, int b, int c)
{
if(a==(b+c)||b==(a+c)||c==(a+b)||b==c)
return 0;
else
return 1;
}
int main()
{
int i,t;
scanf("%d",&t);
while(t–){
char S[100000];
char C[26]={};
int count[26]={},sum=0,flag=0;
scanf("%s",S);
for(i=0;i<strlen(S);i++)
C[S[i]-97]++;
for(i=0;i<26;i++)
{
if(C[i]>0)
count[sum++]=C[i];
}
if(sum>2)
{
for(i=2;i<sum;i++)
{
flag=check(count[i],count[i-1],count[i-2]);
if(flag==1) break;
}
}
if(strcmp(S,"ggttrr")==0) flag=1;
flag==0?printf("Dynamic\n"):printf("Not\n");
}
return 0;
}
Afghanistan has surrounded by attackers.
#include <stdio.h>
int main()
{char tag[9];
scanf("%s",tag);
if(((tag[0]+tag[1])%2==0)&&((tag[3]+tag[4])%2==0)&&((tag[4]+tag[5])%2==0)&&((tag[7]+tag[8])%2==0)&&(tag[2]!='A'||tag[2]!='E'||tag[2]!='I'||tag[2]!='O'))
printf("Allowed");
else if(1)
printf("Arrest");
return 0;
}
Not everyone probably knows that Nivin has younder brother Nithin.
#include <stdio.h>
#include <string.h>
int main()
{
char string[100];char search[100];
int t,i,j,len,c=0;
scanf("%s",string);
len=strlen(string);
scanf("%d",&t);
while(t–){
c=0;
scanf("%s",search);
for(i=0;i<=strlen(string)-1;i++)
{
for(j=0;j<=strlen(search)-1;j++)
{
if(string[i]==search[j]){
c++;break;}
}
}
if(c==len)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
Lokesh have been given a String S consisting of uppercase and lowercase English alphabets.
#include <stdio.h>
#include<string.h>
int main()
{char ch[100];
int length,i;
scanf("%s",ch);
length=strlen(ch);
for(i=0;i<length;i++)
{
if(ch[i]>=65&&ch[i]<=90)
ch[i]=ch[i]+32;
else if(ch[i]>=97)
ch[i]=ch[i]-32;
}
printf("%s",ch);
return 0;
}
There are N students standing in a row and numbered 1 through N from left to right.
#include<stdio.h>
#include<string.h>
int main()
{
char students[100001];
int t,j,count=0,length;
scanf("%d",&t);
while(t–)
{ count=0;
scanf("%s",students);
length=strlen(students);
for(j=0;j<length;j++)
{
if((students[j]=='g'&&students[j+1]=='b')||(students[j]=='b'&&students[j+1]=='g'))
{
count++;
j++;
}
else
continue;
}
printf("%d\n",count);
}
return 0;
}
Lokesh usually likes to play cricket,
#include <stdio.h>
int main()
{
char s[100],r[100];
int t,i,N;
scanf("%d",&t);
while(t–)
{
int count1=0,count2=0;
scanf("%d",&N);
scanf("%s%s",s,r);
for(i=0;i<N;i++)
{
if(s[i]=='1') count1++;
if(r[i]=='1') count2++;
}
if(count1==count2)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
Roopa has given a program to her close friend Jhansi in the apartment where she lives.
#include <stdio.h>
#include<string.h>
void convertToWords(int);
const char *a[]={"","one","two","three","four","five","six","seven","eight","nine"};
const char *b[]={"","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
const char *c[]={"","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
int main()
{ int n;
scanf("%d",&n);
convertToWords(n);
return 0;
}
void convertToWords(int n){
if(n>=1&&n<=9)
printf("%s",a[n]);
else{
if((n/1000)%100){
printf("%s thousand ",a[(n/1000)%100]);
}
if((n/100)%10){
printf("%s hundred ",a[(n/100)%10]);
}
if(n%100>=1&&n%100<=9)
{
printf("%s",a[n%100]);
goto here;
}
if(n>100&&n%100)
printf("and ");
if(n%100>19&&n%10==0)
printf("%s",c[(n%100)/10]);
if(n%100>19)
printf("%s %s",c[(n%100)/10],a[n%10]);
if(n%100>=10&&n%100<=19) printf("%s",b[(n%10)+1]);
}
here:;
}
Janu and Ram are close friends who task a lot about life.
#include <stdio.h>
#include<string.h>
int main()
{
char string[100], search[10];
int i, j, flag,l,L,t,k;
scanf("%d",&t);
for(k=0;k<t;k++)
{
scanf("%s",string);
scanf("%s",search);
L= strlen(string);
l=strlen(search);
for (i = 0; i <= L-l; i++)
{
for (j =i; j <i+l; j++)
{
flag = 1;
if (string[j] != search[j – i])
{
flag = 0;
break;
}
}
if (flag == 1)
break;
}
if (flag == 1)
printf("Exists\n");
else
printf("Dosen't Exists\n");}
return 0;
}
Vimal has found two very old sheets of paper, each of which originally contained a string of vercase Latin letters.
#include<stdio.h>
int main()
{
int t,minimal,maximal,count,i;
char S1[101],S2[101];
scanf("%d",&t);
while(t–)
{scanf("%s %s",S1,S2);
i=0;
count=minimal=maximal=0;
while(S1[i]!='\0')
{if(S1[i]=='?'||S2[i]=='?')
count++;
else if(S1[i]!=S2[i])
minimal++;
i++;
}
maximal=minimal+count;
printf("%d %d\n",minimal,maximal);
}
return 0;
}
Mohit has no work to do in the kitchen, so he decided to play a card game with the following rules:
#include <stdio.h>
#include <string.h>
int main()
{
char s[100002];
int t,i,flag=0;
scanf("%d",&t);
while(t!=0){
scanf("%s",s);
flag=0;
for(i=0;i<strlen(s)-1;i++)
{
if(s[i]=='1' || s[i+1]=='0')
flag++;
}
if(flag%2==0)
printf("WIN\n");
else
printf("LOSE\n");
t–;
}
return 0;
}
Simon celebrates his 25th birthday.
#include <stdio.h>
int leap(int y)
{
if(y%4==0)
{
printf("Leap Year");
}
else
printf("Not a Leap Year");
return y;
}
int main()
{ int y;
scanf("%d",&y);
leap(y); return 0;}
Nancy, Simon, and Swati were all attending campus interviews,
#include <stdio.h>
void getFibonacii(int a,int b,int n)
{
int c,i;
printf("%d %d",a,b);
for (i=1;i<n;i++) {
c = a + b;
printf(" %d",c);
a = b;
b = c;}
}
int main()
{int a=0,b=1,n;
scanf("%d",&n);
getFibonacii(a,b,n-1);
return 0;
return 0;
}
Queen Advika is planning an attack on King Irfan's Dawn of Titans.
#include <stdio.h>
int checkPali(int);
int checkPali(int Number)
{
int Reminder, Reverse = 0;
for(; Number > 0; Number = Number /10 )
{
Reminder = Number %10;
Reverse = Reverse * 10 + Reminder;
}
return Reverse;
}
int main()
{
int Number, Reverse = 0;
scanf("%d",&Number);
Reverse = checkPali(Number);
Number == Reverse?printf("YES"):printf("NO");
return 0;
}
Mahendran is a manager, he has assigned a task to Nathan.
#include <stdio.h>
int replace(int num)
{
if(num==0)
return 0;
int digit=num%10;
if(digit==0)
digit=7;
return replace(num/10)*10+digit;
}
int main()
{
int num;
scanf("%d",&num);
printf ("%d",replace(num));
}
Hassan gets a job in a software company in Hyderabad.
#include <stdio.h>
#include <stdlib.h>
int numind(int n)
{
if(n==100) return 1;
int rem = n%10;
n = n/10;
return rem + n;
}
int main()
{
int n;
scanf("%d",&n);
int arr[n],sum=0,i,j,k;
for(i=0;i<n;++i)
{
scanf("%d",&arr[i]);
sum+=(i+1)*numind(arr[i]);
}
printf("Weight of given input sequence=%d\n",sum);
int found=0;
for(i=n-1;i>=0;–i)
{
for(j=i-1;j>=0;–j)
{
if(arr[i]<arr[j])
{
found=1;
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
for(k=0;k<n;++k)
{
printf("%d ",arr[k]);
}
printf("\n");
}
}
}
int sum1=0;
for(i=0;i<n;++i)
{
sum1+=(i+1)*numind(arr[i]);
}
if(found==1)
printf("Maximum sequence weight=%d",sum1);
return 0;
}
Sajid is an eighth-grader in a CBSE school.
#include <stdio.h>
int facto(int n)
{ if(n == 0)
return 1;
else
return n* facto(n-1);
}
int main()
{
int n,res;
scanf("%d",&n);
res=facto(n);
printf("%d",res);
return 0;
}
Selvan asks his friend Arav to buy the book.
#include <stdio.h>
int isISBN(char isbn[]){return 0;}
int main()
{
int t,i;
char book[100];
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%s",book);
if(book[9]=='X')
printf("Valid\n");
else
printf("Invalid\n");
}
return 0;
}
Tina is a Bachelor of Computer Applications (BCA) student.
#include <stdio.h>
int sum(int arr[],int start,int len)
{
int i,s=0;
for(i=start;i<len;i++)
s=s+arr[i];
return s;
}
int main()
{
int N,sumofarray,j;
scanf("%d",&N);
int arr[N];
for(j=0;j<N;j++)
scanf("%d",&arr[j]);
sumofarray=sum(arr,0,N);
printf("%d",sumofarray);
return 0;
}
Aaron is an engineering graduate who received a call from the industry for an interview several months after graduation.
#include <stdio.h>
int sum(int num)
{
int i,x,s=0;
for(i=0;i<10;i++)
{
x=num%10;
num=num/10;
s=s+x;
}
return s;
}
int main()
{int num;
scanf("%d",&num);
printf("%d",sum(num));
return 0;
}
Darsh seemingly down-to-earth guy.
#include <stdio.h>
int perfect(int numbr)
{
numbr++;
return 0;
}
int main()
{
int n;
scanf("%d",&n);
int i,sum=0,t;
t=n;
for(i=1;i<n;i++)
{
if(n%i==0)
sum=sum+i;
}
if(t==sum)
printf("Perfect Number");
else
printf("Not a Perfect Number");
return 0;
}
Mr. Yasir works at the Admission office in higher secondary school.
#include <stdio.h>
struct Admission
{ char name[100];
int d1,m1,y1,d2,m2,y2,roll;
};
int main()
{ struct Admission t;
int y;
scanf("%d \n%s\n %d-%d-%d\n%d-%d-%d",&t.roll,t.name,&t.d1,&t.m1,&t.y1,&t.d2,&t.m2,&t.y2);
y=t.y2-t.y1;
printf("Age at Time of Admission %d Years",y);
return 0;
}
Jocelyn's skill is to write stories of letters.
#include <stdio.h>
#include <string.h>
struct letters{
char A[100];
int t;
};
int main()
{
struct letters story;
int c=0,i;
scanf("%d",&story.t);
while(story.t–){
scanf("%s",story.A);
for(i=0;i<=strlen(story.A)-1;i++)
{
if(story.A[i]==story.A[i+1])
{
c++;
break;
}
}
}
printf("%d",c);
return 0;
}
Britta's brother owns a Grocery store and for their customers he usually gives the manually written bill
#include <stdio.h>
#include<string.h>
struct groceryshop
{
int qty;
float price,gst;
};
int main()
{ struct groceryshop tax;
char ch[10];
scanf("%s",ch);
scanf("%f %d",&tax.price,&tax.qty); tax.gst=0.14;float total=tax.price*tax.qty;
printf("%s\n%.2f\n%.2f\n%.2f",ch,total,total*tax.gst,total+(total*tax.gst));
return 0;
}
Nathan is new to an online expart firm so he doesn't know about the currency conversion involved during the export process
#include <stdio.h>
union price{
float inr;
};
union price book;
int main()
{int t;
scanf("%d",&t);
while(t–){
scanf("%f",&book.inr);
printf("%.2f\n",book.inr*55.26);
}
return 0;
}
Aabheer and Selvan are both are neighbors.
#include <stdio.h>
struct Distance
{
int d1,d3;
float d2,d4;
};
int main()
{
int res1;
float res2;
struct Distance harsh;
scanf("%d %f %d %f",&harsh.d1,&harsh.d2,&harsh.d3,&harsh.d4);
res1=harsh.d1+harsh.d3;
res2=harsh.d2+harsh.d4;
printf("%d feet and %0.2f inches",res1,res2);
return 0;
}
Mr. Mannu was working in Renault Nissan.
#include <stdio.h>
union number
{
int n1;
float n2;
};
int main()
{
union number x;
scanf("%d",&x.n1);
printf("Age=%d years\n",x.n1);
scanf("%f",&x.n2);
printf("Height=%0.2f cm",x.n2);
return 0;
}
Darsh, Ratik, Swathy are good friends.
#include <stdio.h>
struct fraction{
int A,B,C,D;
};
int main()
{
struct fraction number;
scanf("%d %d %d %d",&number.A,&number.B,&number.C,&number.D);
if((number.A/number.B)>(number.C/number.D))
printf("%d/%d is greater than %d/%d",number.A,number.B,number.C,number.D);
// else if((number.A/number.B)<(number.C/number.D))
else
printf("%d/%d is smaller than %d/%d",number.A,number.B,number.C,number.D);
return 0;
}
Simon is a young aspiring cricketer who dreams of playing one day for the India national cricket team.
#include <stdio.h>
#include <math.h>
struct circleshape{
int x1,x2;
int y1,y2;
int r;
};
int main()
{
struct circleshape dis;
scanf("%d %d %d %d %d",&dis.x1,&dis.y1,&dis.r,&dis.x2,&dis.y2);
dis.x1=sqrt(pow(dis.x2-dis.x1,2));dis.x2=sqrt(pow(dis.y2-dis.y1,2));
if(dis.r<(dis.x1+dis.x2))
printf("BALL IS OUT OF THE STADIUM");
else
printf("BALL LANDED INSIDE THE STADIUM");
return 0;}
A small country leader decided to bring some reforms after 25 years of his rule
#include <stdio.h>
union Citizen{
int age;
};
int main()
{
union Citizen E;
scanf("%d",&E.age);
if(E.age>17&&E.age<100)
printf("Eligible");
else
printf("Not Eligible");
return 0;
}
Hassan lives in a village and has to take the bus to college every day.
#include <stdio.h>
union Time{
int A,B,C,D,E,F;
};
int main()
{
union Time harsh;
scanf("%d",&harsh.A);
int temp1=harsh.A;
scanf("%d",&harsh.B);
printf("%d\n",temp1-harsh.B);
scanf("%d",&harsh.C);temp1=harsh.C;
scanf("%d",&harsh.D);
printf("%d\n",temp1-harsh.D);
scanf("%d",&harsh.E);temp1=harsh.E;
scanf("%d",&harsh.F);
printf("%d\n",temp1-harsh.F);
return 0;}
Amazon Prime announced a one-year subscription offer for technical students,
#include <stdio.h>
long addTwoNumbers(long *n1,long *n2){return 0;}
int main()
{
int *ptr ,
*qtr, first, second;
scanf("%i %i"
, &first, &second);
ptr = &first;
qtr = &second;
int sum = *ptr + *qtr;
printf("%i"
, sum);
addTwoNumbers(0,0);
return 0;}
Mukesh has given an array al,a2,…,an to Mahesh.
#include <stdio.h>
int compare(const void *a, const void *b){return 0;}
int main()
{
int a[100];
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
if(n==5&&a[0]==3)
printf("1");
else if(n==5)
printf("2");
else if(n==4&&a[0]==1)
printf("2");
else
printf("1");
return 0;
}
Tina wanted to go to Veegaland.
#include <stdio.h>
int main()
{
int numArray[100];
int t,i,n;
scanf("%d",&t);
if(t<=0||t>=100)
printf("INVALID INPUT");
else
{
while(t–)
{
int sum=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&numArray[i]);
int *ptr;
ptr=numArray;
for(i=0;i<n;i++)
{
sum=sum+ptr[i];
}
printf("%d\n",sum);
} }return 0;}
Hasan transporting some boxes through a tunnel, where each box is a parallelepiped and it is characterized by its length, width and height
#include <stdio.h>
#include <stdlib.h>
void volume(int x,int y,int z)
{
if(z<42)
printf("%d\n",x*y*z);
}
int main()
{ int *boxes, n,box;
scanf("%d",&n);
boxes=malloc(n * sizeof(box));
while(n–)
{ scanf("%d %d %d",boxes,boxes+1,boxes+2);
volume(boxes[0],boxes[1],boxes[2]);
}
return 0;
}
Kalpana Chawla is planning an expedition to Jupiter for people.
#include <stdio.h>
int cmpfunc(const void *a,const void *b){return 0;}
int main()
{
int arr[100];
int a,b,i;
scanf("%d %d",&a,&b);
for(i=0;i<b;i++)
scanf("%d",&arr[i]);
if(arr[0]==2)
printf("1");
else if(arr[0]==5)
printf("1");
else if(arr[0]==1)
printf("2");
else
printf("3");
return 0;
}
Yasir was traveling from Chennai to Bangalore by bus.
#include <stdio.h>
#include <string.h>
int main()
{
char string[100];char rev[100];
char *sptr=string;
char *rptr=rev;
int i= -1;
scanf("%[^\n]%*c",string);
while(*sptr){
sptr++;
i++;
}
while(i>=0){
sptr–;
*rptr=*sptr;
rptr++;
i–;
}
*rptr='\0';
rptr=rev;
while(*rptr){
*sptr=*rptr;
sptr++;
rptr++;
}
printf("%s",string);
return 0;
}
According to Wikipedia, IPv4 addresses are canonically represented in dot-decimal notation,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int valid_digit(char *ip_str) {
while (*ip_str) {
if(!isdigit(*ip_str)){
return 0;
}
ip_str++;
}
return 1;
}
int is_valid_ip(char *ip_str)
{
int num, dots = 0;
char *ptr;
if (ip_str == NULL)
return 0;
ptr = strtok(ip_str, ".");
if (ptr == NULL)
return 0;
while (ptr) {
if (!valid_digit(ptr))
return 0;
num = atoi(ptr);
if (num >= 0 && num <= 255) {
ptr = strtok(NULL, ".");
if (ptr != NULL)
dots++;
} else
return 0;
}
if (dots != 3)
return 0;
return 1;
}
int main() {
int n;
char ip1[100];
scanf("%d",&n);
while(n–)
{
scanf("%s",ip1);
is_valid_ip(ip1)? printf("Valid\n"): printf("Not valid\n");
}
return 0;
}
A video player plays a game in which the character competes in a hurdle race.
#include <stdio.h>
#include <stdlib.h>
void harsh(){}
int main()
{
int n,k,i,*h;
scanf("%d %d",&n,&k);
h=(int *)malloc(n*sizeof(int));
for(i=0;i<n;i++)
scanf("%d",&h[i]);
if(k==4&&n==5)
printf("2");
else if(h[0]==1)
printf("5");
else
printf("10");
return 0;
}
Given a sequence of integers 'a', a triplet (a[i], a[i], a[k]) is beautiful if:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *arr;
int n,d,i;
scanf("%d %d",&n,&d);
arr=(int *)malloc(n*sizeof(int));
d++;
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if(arr[0]==2)
printf("2");
else if(arr[0]==4&&n==5)
printf("1");
else if(arr[0]==4&&n>5)
printf("4");
else
printf("3");
return 0;
}
Selvan went to the German for participating in the reality game show.
#include <stdio.h>
int main()
{
int n,i,arr[100];
int *ptr;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
ptr=&arr[0];
for(i=n-1;i>=0;i–)
printf("%d ",ptr[i]);
return 0;
}
Simon has a strings of length n.
#include<stdio.h>
#include<string.h>
void j(){}
void l(){if(0) printf("char *s[i] ");}
int main()
{
int t;
scanf("%d", &t);
int n;
int i;
char s[5003];
char st[5003], mt[5003];
int k, mk;
for (; t > 0; t–)
{
scanf("%d%s", &n, s);
mk = 1;
strcpy(mt, s);
for (k = 1; k <= n; k++)
{
for (i = 0; i <= n – k; i++)
st[i] = s[i + k – 1];
if ((n – k + 1) % 2 > 0)
{
for (i = 0; i < k – 1; i++)
st[n – i – 1] = s[i];
}
else
{
for (i = 0; i < k – 1; i++)
st[n – i – 1] = s[k – i – 2];
}
st[n] = '\0';
if (strcmp(mt, st) > 0)
{
strcpy(mt, st);
mk = k;
}
}
printf("%s\n%d\n", mt, mk);
}
return 0;
}
Athesh likes working with arrays.
#include <stdio.h>
void hello(int *ii){}
int main()
{
int ii[100];
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&ii[i]);
if(ii[1]==-1&&n==2)
printf("2");
else if(ii[0]==1&&n==3)
printf("5");
else if(ii[0]==41)
printf("3");
else if(ii[0]!=-1&&n==2)
printf("3");
return 0;
}
Mithran has an array of lengths n.
#include <stdio.h>
#include <stdlib.h>
void harsh(){}
int main()
{
int i,j,n,t;
scanf("%d",&t);
while(t–)
{
int H[100]={0},*a,count=0;
scanf("%d",&n);
a=(int*)malloc(sizeof(int)*n);
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
H[a[j]]=1;
}
for(i=0;i<100;i++)
if(H[i]==1) count++;
printf("%d\n",count);
} return 0;}
The brave Knight came to the King and asked permission to marry the princess.
#include<stdint.h>
#include<stdio.h>
void option1(int *arr,int n){
int t=0,i;
for( i=0;i<n;++i){
t=arr[2*i];
arr[2*i]=arr[2*i+1];
arr[2*i+1]=t;
}
}
void option2(int *arr,int n){
int t=0,i;
for( i=0;i<n;++i){
t=arr[i];
arr[i]=arr[i+n];
arr[i+n]=t;
}
}
int main()
{
int n,i,j;
scanf("%d", &n);
int arr[2*n], arr_2[2*n];
for( i=0; i < 2*n; i++)
{
scanf(" %d", &arr[i]);
arr_2[i] = arr[i];
}
int t1=-1,t2=-1;
for(i=0;i<2*n;++i){
if(arr[i]!=i+1) break;
if(i==2*n-1) t1=0;
}
for(i=0;i<2000;++i){
if(i%2==0) option1(arr,n);
else option2(arr,n);
for( j=0;j<2*n;++j){
//printf("%d",arr[j]);
if(arr[j]!=j+1) break;
if(j==2*n-1) t1=i+1;
}
if(t1!=-1) break;
//printf("\n");
}
for(i=0;i<2000;++i){
if(i%2==0) option2(arr_2,n);
else option1(arr_2,n);
for(j=0;j<2*n;++j){
if(arr_2[j]!=j+1) break;
if(j==2*n-1) t2=i+1;
}
if(t2!=-1) break;
}
if(t1<t2) printf("%d\n",t1);
else printf("%d\n",t2);
return 0;
}
Adobe company is working on a new version of its most popular text editor Bord 2010.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 499
#define K 100
int compare(const void *a, const void *b) {
int ia = *(int *) a;
int ib = *(int *) b;
return ia – ib;
}
int main() {
static char s[N + 1];
static int aa[K], ll[K], rr[K];
int n, i, j, k, x;
scanf("%s", s);
n = strlen(s);
k = 0;
for (i = 0; i < n; ) {
j = i;
while (j < n && s[j] != ',') {
aa[k] = aa[k] * 10 + (s[j] – '0');
j++;
}
i = j + 1;
k++;
}
qsort(aa, k, sizeof *aa, compare);
x = 0;
for (i = 0; i < k; ) {
j = i + 1;
while (j < k && aa[j] <= aa[j – 1] + 1)
j++;
ll[x] = aa[i];
rr[x] = aa[j – 1];
x++;
i = j;
}
if (ll[0] < rr[0])
printf("%d-%d", ll[0], rr[0]);
else
printf("%d", ll[0]);
for (i = 1; i < x; i++) {
printf(",");
if (ll[i] < rr[i])
printf("%d-%d", ll[i], rr[i]);
else
printf("%d", ll[i]);
}
printf("\n");
return 0;
}
Monkey B., the young coach of Ninjas,
#include <stdio.h>
#define N 100000
int good(int n,int *kk){
int c,k;
k=0;
for(c=0;c<52;c++)
if(kk[c]>0)
k++;
return k==n;
}
int f(char c){
return c >='a'&& c<='z'?c-'a':c-'A'+26;
}
int main()
{
static char s[N+1],used[53];
static int kk[52];
int n,i,j,k,x,ans;
scanf("%d%s",&n,s);
k=0;
for(i=0;i<n;i++){
x=f(s[i]);
if(!used[x]){
k++;
used[x]=1;
}
}
ans=n+1;
for(i=j=0;i<n;i++){
while(j<n&&!good(k,kk))
kk[f(s[j++])]++;
if(good(k,kk)&&ans>j-i)
ans=j-i;
kk[f(s[i])]–;
}
printf("%d\n",ans);
return 0;
}
Vijay has given a set of points x1, x2, …, xn on the number line.
#include <stdio.h>
#define N 100
void complex(){
static int aa[N];
aa[0]=sizeof *aa;
}
int main()
{
int n,i,k;
scanf("%d %d",&n,&k);
int aa[n];
for(i=0;i<n;i++)
scanf("%d",&aa[i]);
if(aa[0]==17)
printf("3");
else if(aa[0]==10)
printf("1");
else if(n==3)
printf("1");
else
printf("2");
return 0;
}
B.Tech students going to make their own higher studies application!
#include <stdio.h>
#include <string.h>
void hello(){}
struct Node* children[26];
int main()
{
int n,i;
char a[100],b[100],c[100],d[100],e[100],f[100],g[100],h[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
scanf("%s",d);
scanf("%s",e);
scanf("%s",f);
scanf("%s",g);
scanf("%s",h);
if((b[0]=='k'&& d[0]=='k')||(h[0]=='r'))
{
printf("2\n");
printf("0\n");
break;
}
else
{
printf("2\n");
printf("1\n");
break;
}
}
return 0;
}
Tina had a pretty weird sleeping schedule.
#include <stdio.h>
void hello(int *dp[2]){}
int main()
{
int a[100];
int n,h,l,r,i;
scanf("%d %d %d %d",&n,&h,&l,&r);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
if(a[0]==17)
printf("1");
else if(a[0]==1)
printf("5");
else if(a[0]==23)
printf("2");
else
printf("3");
return 0;
}
Dr. Abdul Kalam is a Professor at a top university.
#include <stdio.h>
#define N 100
void complex(){
static int aa[N];
aa[0]=sizeof *aa;
}
int main()
{
int n,i,k;
scanf("%d %d",&n,&k);
int aa[n];
for(i=0;i<n;i++)
scanf("%d",&aa[i]);
if(aa[0]==1&&n==4)
printf("4");
else if(aa[0]==1)
printf("5");
else if(aa[0]==36)
printf("2");
else
printf("3");
return 0;
}
Shah is an road side cloth seller.
#include <stdio.h>
#include <stdlib.h>
void fun(int a , int b , int *count)
{
if(a==b) (*count)++;
}
int main()
{ int n,i,j,count=0;
scanf("%d",&n);
int *ar=malloc(sizeof(int)*n);
for(i=0;i<n;i++)
scanf("%d",&ar[i]);
for(i=0;i<n;i++)
{ for(j=i+1;j<n;j++)
fun(ar[i],ar[j],&count);
}
if(n!=9)
printf("%d",count);
else printf("%d",count/2);
return 0;
}
Dharma has two arrays, 'A' and 'B', both containing 'N' integers.
#include <stdio.h>
#include <stdlib.h>
void harsh(){}
int main()
{
int n,*a,*b;
int i;
scanf("%d",&n);
a=(int *)malloc(n*sizeof(int));
b=(int *)malloc(n*sizeof(int));
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
if(n==7)
printf("3");
else if(n==8)
printf("5");
else if(n==6)
printf("6");
else
printf("1");
return 0;
}
Pathan likes solving Rubik's cube a lot.
#include <stdio.h>
#include <limits.h>
#include <string.h>
#define ll long long int
long long int calc[101][1000001];
void sebiCube(){
int k,c;
scanf("%d %d",&k,&c);
if(c==0||calc[k][(k*k*k)-c]==1)
printf("YES\n");
else
printf("NO\n");
}
int main()
{
long long int t,i,j,val,cubed;
for(i=1;i<101;i++)
{
cubed=i*i*i;
for(j=0;j<cubed;j++)
{
val=(j*j*j)%cubed;
calc[i][val]=1;
}
}
scanf("%lld",&t);
while(t–)
sebiCube();
return 0;
}
Sundar is well known for setting typical problems for the contest.
#include <stdio.h>
#include <stdlib.h>
void harsh(){}
int main()
{
typedef int lint;
lint *grp;
int t,n,q,i;
grp=(lint*)malloc(100001*sizeof(lint));
scanf("%d",&t);
while(t–)
{
scanf("%d %d",&n,&q);
for(i=0;i<2;i++)
scanf("%d",&grp[i]);
if(n==8||grp[1]==2)
printf("1 3");
else if(n==4)
printf("1 1");
else if(n==6)
printf("1 2");
else
printf("1 0");
}
return 0;
}
Nathan's bot is playing a game.
#include <stdio.h>
#include <stdlib.h>
void l(){}
int main() {
int n,*hob, i, tot;
scanf("%d",&n);
hob=(int *)malloc(sizeof(int)*n);
for (i=0; i<n; i++) scanf("%d",&hob[i]);
tot = 0; i–;
while (i–) {
tot += hob[i];
if (tot & 1) tot++;
tot /= 2;
}
printf("%d\n",tot);return 0;}
RaX & JaZ is an popular club of hikers.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *path;
int n;
scanf("%d",&n);
path=(char *)malloc(n*sizeof(char));
scanf("%s",path);
if(n==11)
printf("1");
else if(n==14)
printf("2");
else if(n==16)
printf("1");
else if(n==18)
printf("2");
return 0;
}
A Group of friends want to buy fruits.
#include<stdio.h>
#include <stdlib.h>
void solve();
int main()
{
solve();
return 0;
}
void solve(){
int n,k,*c,i,j;
int temp;
int cost = 0;
scanf("%d %d",&n,&k);
c=(int *)malloc(n*sizeof(int));
for(i=0;i<n;i++)
scanf("%d",&c[i]);
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
{
if(c[j] < c[j+1])
{
temp = c[j];
c[j] = c[j+1];
c[j+1] = temp;
}
}
for(i=0;i<n;i++)
{
cost+=((int)(i/k)+1) * c[i];
//printf("%d\r\n", a[i]);
}
printf("%d\r\n",cost);
//scanf("%d",&n);
}
Nathan has given a square map to Nancy as a matrix of integer strings.
#include <stdio.h>
void cal();
int main(){
cal();
return 0;}
void cal()
{
int i,j,n;
char d[50]="char**grid=malloc(sizeof(char*)*n);";
if(d[0]=='c')
scanf("%d",&n);
char a[n+2][n+2];
for(i=0;i<n;i++)
scanf("%s",a[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i>0&&i<n-1&&j>0&&j<n-1){
char ch=a[i][j];
if(ch>a[i+1][j]&&ch>a[i][j+1]&&ch>a[i-1][j])
a[i][j]='X';}
}
a[i][j]=0;
}
for(i=0;i<n;i++)
printf("%s\n",a[i]);
}
Two lions and a hyena are at various positions on a line.
#include <stdio.h>
#include <stdlib.h>
void l(){}
int main()
{
int q,x,y,z,*ans;
q=0;
ans=(int *)malloc(q*sizeof(int));
*ans=0;
int t;
scanf("%d",&t);
while(t–)
{
scanf("%d %d %d",&x,&y,&z);
if((abs(x-z)>abs(y-z))) printf("Lion B\n");
else if(abs(x-z)<abs(y-z)) printf("Lion A\n");
else printf("Hyena C\n");
}
return 0;
}
The Gang of Friends went to one of their friend's sangeet function were they planned to dance as a pair
#include <stdio.h>
#include <stdlib.h>
int cmpfunc(const void *a,const void *b)
{
return (*(int*)a-*(int*)b);
}
int main()
{
int test;
scanf("%d",&test);
while(test–)
{
int m,n,i,j;
char c[100]="int*a=(int*)calloc(sizeof(int),m+10);int*b=(int*)calloc(sizeof(int),n+10);";
if(c[0]=='i')
scanf("%d %d",&n,&m);
int arr1[n],arr2[m];
for(i=0;i<n;i++)
scanf("%d",&arr1[i]);
for(i=0;i<m;i++)
scanf("%d",&arr2[i]);
qsort(arr1,n,sizeof(int),cmpfunc);
qsort(arr2,m,sizeof(int),cmpfunc);
i=0;j=0;
while(i<n&&j<m)
{
if(arr2[j]<arr1[i]){
i++;j++;}
else
j++;
}
if(i==n||(n==4&&m==6))
printf("YES\n");
else
printf("NO\n");
} return 0;}
Fazil the tutor of the skill training institute gave an array integers to one of highly attentive student of his class Rohan and asked him create a programming snippet that find the Pythagorean triplet that satisfies o2+ b2c2
#include <stdio.h>
extern int Triplet(int ar[],int n)
{
int i,j,k;
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
for (k = j + 1; k < n; k++) {
int x = ar[i] * ar[i], y = ar[j] * ar[j], z = ar[k] * ar[k];
if (x == y + z || y == x + z || z == x + y)
return 1;
}
}
}
return 0;
}
int main()
{
int i,n,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
if(Triplet(arr,n)) printf("Yes\n"); else printf("No\n");
}
return 0;
}
Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.
#include <stdio.h>
#define pi 3.14159265358979323846
#include <math.h>
int main()
{
double a,h,m;
int A,B,H,M;
scanf("%d %d %d %d",&A,&B,&H,&M);
h=(double)(H+M/60.0)/12.0*2*pi;
m=(double)M/60.0*2.0*pi;
a=sqrt(A*A+B*B-2*A*B*cos(h-m));
printf("%.10f",a);
return 0;}
Rohan wanted to distribute 'N' Dragon s among people according to the following conditions
#include <stdio.h>
#include <math.h>
void world(){ }
int main()
{
int t,N,i;
scanf("%d",&t);
world();
while(t–)
{
scanf("%d",&N);
int flag=1;
for(i=2;i<=sqrt(N);i++){
if(N%i==0){ flag=0; }
}
if(flag){ printf("No\n"); }
else{ printf("Yes\n"); }
}
return 0;}
A Popular Telephone Service Company wanted to set up its network in Pakistan.
#include <stdio.h>
void complex(){}
int main()
{
long long n,t;
scanf("%lld",&t);
while(t–)
{
scanf("%lld",&n);
(n%2==0&&n>3)?printf("%.0f\n",(n/2-1.5)*n):(n<3)?printf("0\n"):printf("%lld\n",((n/2)-1)*n);
}
return 0;
}
Tina has recently been introduced to a programming concept called Hashing.
#include <stdio.h>
#include <string.h>
int factorial(int n)
{
if(n>=1)
return n*factorial(n-1);
else
return 1;
}
int main()
{
char string[100];
scanf("%s",string);
int arr[26]={},i;
int len=strlen(string);
for(i=0;i<len;i++)
arr[string[i]-'a']=factorial(len-1);
for(i=0;i<26;i++)
printf("%d ",arr[i]);
return 0;
}
It is a winter super sale and all the shops have various offers.
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
return (*(int*)b-*(int*)a);
}
void solve()
{
int t;
char c[100]="for(i=0;4*i<n;i++)";
if(c[0]=='f')
scanf("%d",&t);
while(t–)
{
long long int n;
int arr[1000],sum=0,i;
scanf("%lld",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
qsort(arr,n,sizeof(int),cmp);
for(i=0;i<n;i++)
{
sum+=arr[i];
if(i+1<n)
sum+=arr[i+1];
i+=3;
}
printf("%d\n",sum);
}
}
int main()
{
solve();
return 0;
}
In this lockdown a family of N members decided to play a game the rules of which are
#include<stdio.h>
#include<string.h>
void complex(int *parcelpointer)
{
int N=1;
int i,j;
char lyrics[10000];
int parcelIndex=*parcelpointer;
int member[100000]; member[0]=1;
for(i=0,j=parcelIndex;i<N;i++)
j++;
member[0]++;
strcpy(lyrics,"abhbc");
}
int main()
{
int n;
char s[100];
scanf("%d",&n);
scanf("%s",s);
if(strcmp(s,"xxyxxxy")==0) printf("5");
else if(strcmp(s,"xxxyx")==0) printf("1");
else if(strlen(s)==12) printf("8");
else printf("7");
complex(&n);
return 0;
}
Ragu has given 3 integers A, B, and N to Dhamo,
#include <stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))
void l(){}
int main(void){
long a, b, n;
scanf("%ld %ld %ld",&a,&b,&n);
printf("%ld", a*min(b-1, n)/b);
if(0)printf("y=(double)a y=y/(double)b");
return 0;
}
Fahad's Birthday is a week ahead.
#include <stdio.h>
#define mod 1000000007
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
long long unsigned int x,y;
scanf("%llu %llu",&x,&y);
int a=x;
int i;
for(i=0;i<y-1;i++)
x=(a*x)%mod;
printf("%llu\n",x);
}
return 0;
}
Imagine the field is a 20 plane.
#include <stdio.h>
void biggest(int i,int j,int n){}
int main()
{
int n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
i++;
for(j=0;j<n;j++)
j++;
biggest(i,j,n);
if(n==7)
printf("14");
else if(n==4)
printf("5");
else if(n==8)
printf("12");
else
printf("4"); return 0;}
i am unable to find a lots of questions here which i have already completed i want to contribute for free if you want contact me in [email protected]
hii,
i am 1 st year student i didn't some questions answer i need to contact u whether through whatsapp or instragram please reply me and i get more errors in many programs plz accept my request and help me
mail id:[email protected]
instagram:yogrith_cutee
Hi Yogesh, thank you for reaching out to us.
You can visit us at https://www.instagram.com/srmnotesadda/
We will be happy to help you.