C Questions Answers-Operators and Expressions(Part II)


C operators and expressions(PartII)

1. What is the output of the following C program?
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(){
  int x=10,y=15;
  int mul=x*y;
  printf("%d*%d=%d",x,y,mul);

getch();
return 0;
}
Check answer 2. What is the output of the following C program?
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(){
  float in_m,foot,yard,cent,meter;
  printf("Enter a measurement in inches:");
  scanf("%f",&in_m);
  foot=12*in_m;//1 foot=12 inches
  yard=36*in_m;//1 yard=36 inches
  cent=in_m/2.54f;//1 inch=2.54 centimeters
  meter=39.37*in_m;//1 meter=39.37 inches
  printf("%0.2ffeet=%0.2fyards=%0.2fcentimeters=%0.2f   meters",foot,yard,cent,meter);

 getch();
 return 0;
}
Check answer 3. What is the output of the following C program?
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(){
  int x;
  int f,m,l;
  printf("Enter 3 digit-integer number:");
  scanf("%d",&x);
  f=x/100;
  l=x%10; m=(x/10)%10;
  printf("%-2d %-2d %-2d\n",f,m,l);
  printf("%-2d %-2d\n",m,l);
  printf("%-2d",l);

  getch();
  return 0;
}
Check answer


Comments




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.