Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
#include<stdio.h>
main(){
printf(“Allhamdullilah”);
}
Answer2:
#include<stdio.h>
main(){
char firstname[10],secondname[10];
printf("Enter your First name:\n");
scanf("%s",&firstname);
printf("Enter your Last name\n");
scanf("%s",&secondname);
printf("Welcome %s %s",firstname,secondname);
}
Answer 3:
x is used as variable name because x is alphabet.
99bottles is not used as variable name because variable name never start
with a number
July2009 can be used as variable name because variable name can contain
number but not at start of variable name
theSalesFigureForFiscalYear also be used as variable name be it contain
only alphabet
r&d cannot be variable name because it contain special symbol
grade_report is used as variable name
Answer 4:
72=amount is not valid because in assignment statement there must be first
variable then assigning a value to variable.
Answer 5:
The Output is The value isval.
Answer 6:
Yes Sales is different from sales because C language is case sensitive language
which means if you declare variable in small alphabets then you must write name
of variable in small alphabets in the program.
Answer 7:
#include<stdio.h>
main(){
float km;
int convert;
printf("Enter a Kilometers:");
scanf("%f",&km);The
convert=(km*1000);
printf("Kilometers in meters equal to %d",convert);
}
Answer 8:
#include<stdio.h>
main(){
float liter;
int ,mililiters;
printf("Enter Liters");
scanf("%f",&liters);
mililiters=(liters*1000);
printf("Liters in mililiters is equal to %d",mililiters);
}
Answer 9:
Integer Division:
#include<stdio.h>
main(){
printf("Enter an Integer Numerator and Denominator:");
int n,d,i;
scanf("%d %d",&n,&d);
i=(n/d);
printf("The Answer is %d",i);
}
Real Division:
#include<stdio.h>
main(){
printf("Enter an Real Number Numerator and Denominator:");
float n,d;
float i;
scanf("%f %f",&n,&d);
i=(n/d);
printf("The Answer is %.1f",i);
}
Answer 10:
#include<stdio.h>
main()
{
int i;
float f;
printf("Enter an integer and float value:");
scanf("%d %f",&i,&f);
printf("You Entered %i and %.2f",i,f);
}
Answer 11:
#include<stdio.h>
main(){
int a,b,c;
float d;
printf("Enter two value to sum,multiply and subtract:");
scanf("%d %d",&a,&b);
// For Addition
c=a+b;
printf("Sum is equal to %d\n",c);
// For Multiplication
c=a*b;
printf("Multiplication is equal to %d\n",c);
//For Subtraction
c=a-b;
printf("Subtraction is equal to %d\n",c);
// For Division
d=a/b;
printf("Division is equal to %.1f",d);
return 0;
}
Answer 12:
#include<stdio.h>
main(){
int a,b,c=0,d,e,f=0,g,h,i;
printf("Enter Coins you have:");
scanf("%d",&a);
printf("Enter Rupees(notes) you have:");
scanf("%d",&b);
while(c<a){
printf("\nCoin Number:");
scanf("%d",&e);
switch(e)
{ case 1:
d=d+1;
++c;
break;
case 2:
d=d+2;
++c;
break;
case 5:
d=d+5;
++c;
break;
default:
printf("Number must be 1,2,5\n");
}}
while(f<b){
if(h==10)
h=10;
printf("Rupees number:\n");
scanf("%d",&g);
switch(g)
{
case 10:
h=h+10;
f++;
break;
case 20:
h=h+20;
f++;
break;
case 50:
h=h+50;
f++;
break;
default:
printf("Number must be 10,20,50\n");
}}
i=d+h;
printf("Total money is equal to %d",i);
}
Answer 13:
#include<stdio.h>
main(){
int speed=100;
int time=10;
int distance;
printf("Speed=100km/h\n");
printf("Time=10hours\n");
distance=(speed*time)*1000;
printf("Distance in meters=%d",distance);
}
Answer 14:
#include<stdio.h>
main(){
int a,trip;
printf("How much money you have in your Motorway E-Tag Card:");
scanf("%d",&a);
if(a>0){
trip=a/45;
printf("Your Cost of one Trip is 45 Rupees.\nYou can made %d trips",trip);
}
else
printf("Sorry Rupees Never be Negative");
}
Answer 15:
#include<stdio.h>
main(){
int a,b,c,average;
printf("Enter Marks you got in your three subjects:");
scanf("%d %d %d",&a,&b,&c);
if(a>=0&&b>=0&&c>=0){
average=(a+b+c/3);
printf("The Average of your marks=%d",average);
}
else
printf("Sorry Invalid");
}
Answer 16:
#include<stdio.h>
#include<math.h>
main(){
float total,obt;
float per;
printf("Enter your obtained marks:"); //Obtained Marks
scanf("%f",&obt);
printf("Enter your total marks:"); //Total Marks
scanf("%f",&total);
per=(obt*100)/total; //Percentage Formula
printf("Your Persentage is %.2f",per);
}
Answer 17:
#include<stdio.h>
#include<math.h>
main(){
int a,house,medical_allowance,convince_allowance,salary;
printf("Enter your Salary:");
scanf("%d",&a);
house=(a*0.15);
medical_allowance=(a*0.10);
convince_allowance=(a*0.05);
salary=(house+medical_allowance+convince_allowance);
printf("Your Total salary is %d",salary);
}
Answer 18:
#include<stdio.h>
main(){
float a,b,c;
printf("Enter Length of Rectangle:\n");
scanf("%f",&a);
printf("Enter Width of Rectangle:\n");
scanf("%f",&b);
c=a*b;
printf("Area is equal to %.2f",c);
}
Answer 19:
#include<stdio.h>
#include<math.h>
int main()
{
int x,y;
printf("If user enter -3 in f(x)=|x^3-20|:");
printf("\nthen Answer is 47\n");
printf("Enter a value of 'X' for f(x)=|x^3-20|:");
scanf("%d",&x);
y=abs((x*x*x)-20);
printf("%d",y);
return 0;
}