Вы находитесь на странице: 1из 7

Chapter No.

– 1

Getting Started
Questions
SECTION A
Que: Which of the following are invalid variable names and why?

B'day
Invalid : No special symbols are allowed

while
Invalid: keywords cannot be used variablem name

$hello
Invalid: No special symbols are allowed.

#HASH
Invalid: No special symbols are allowed.

dot.
Invalid: No special symbols are allowd.

number
Valid

totalArea
Valid

_main()
Invalid: No special symbols are allowed.

temp_in_Deg
Valid

total%
Invalid: No special symbols are allowed.

1st
Invalid: Variable name cannot be start with a number.

stack-queue
Invalid: No special symbols are allowed.

variable name
Invalid: No white space is allowed.

%name%
Invalid: No special symbols are allowed.

salary
Valid

SECTION B
Que: State whether the following statements are True or False.

(a) False : It can also be used in other operating systems.

(b) True

(c) True

(d) False: A character constant can hold only one character.

(e) True

(f) True

(g) False: A C statement ends with ';' New line is not


necessary.

(h) True

(i) True

(j) True

(k) False: No spaces or other characters are allowed between


an integer constants.
(l) True

(m) True

(n) True

(o) True

(p) False: It is done by compiler.

SECTION C

Que: Ramesh’s basic salary is input through the keyboard. His dearness allowance is
40% of basic salary, and house rent allowance is 20% of basic salary. Write a program
to calculate his gross salary.

#include<stdio.h>
#include<conio.h>
int main()
{
int sal;
float gros_sal;
printf("Enter the basic salary of Ramesh : ");
scanf("%d", &sal);

//salary calculated
gros_sal=sal+(sal*40/100)+(sal*20/100);

printf("%f is the gross salary of Ramesh.", gros_sal);

getch();
return 0;
}

Que: The distance between two cities (in km.) is input through the keyboard. Write a
program to convert and print this distance in meters, feet, inches and centimeters.

#include<stdio.h>
#include<conio.h>
int main()
{
float dis;

printf("Enter the distance between cities in kilo metres


: ");
scanf("%f", &dis);
printf("\n%f is the distance between them in meters.",
dis*1000);
printf("\n%f is the distance between them in feet.",
dis*3280.8399);
printf("\n%f is the distance between them in inches.",
dis*39370.0788);
printf("\n%f is the distnace between them in
centimeters", dis*100000);

getch();
return 0;
}

Que: If the marks obtained by a student in five different subjects are input through the
keyboard, find out the aggregate marks and percentage marks obtained by the student.
Assume that the maximum marks that can be obtained by a student in each subject is
100.

#include<stdio.h>
#include<conio.h>
int main()
{
float a,b,c,d,e;

printf("Enter the marks out of 100 in five subjects of


the student : ");
scanf("%f%f%f%f%f", &a,&b,&c,&d,&e);

//his total marks


printf("\n%f is the aggregate marks obtained by him.",
a+b+c+d+e);

//his percentage marks


printf("\n%f is the percentage marks obtained by him.",
(a+b+c+d+e)/5);

getch();
return 0;
}
Que: Temperature of a city in Fahrenheit degrees is input through the keyboard. Write
a program to convert this temperature into Centigrade degrees.

#include<stdio.h>
#include<conio.h>
int main()
{
float f,c;
printf("Enter the temperature in Fahrenheit : ");
scanf("%f", &f);

//conversion of temperature
c=(f-32)*100/180;

printf("\n%f is that temperature in celcius.", c);

getch();
return 0;
}

Que: The length & breadth of a rectangle and radius of a circle are input through the
keyboard. Write a program to calculate the area & perimeter of the rectangle, and the
area & circumference of the circle.

#include<stdio.h>
#include<conio.h>
int main()
{
float l,b,r;

printf("Enter the length and breadth of the rectangle :


");
scanf("%f%f", &l,&b);

//rectangle calculations
printf("\n%f is the area of the rectangle.", l*b);
printf("\n%f is the perimeter of the rectangle.", l+b);

//circle calculations
printf("\n\nEnter the radius of the circle : ");
scanf("%f", &r);
printf("\n%f is the area of the circle.", 3.14*r*r);
printf("\n%f is the perimeter of the circle.",
2*3.14*r);

getch();
return 0;
}
Que: If the total selling price of 15 items and the total profit earned on them is input
through the keyboard, write a program to find the cost price of one item.

#include<stdio.h>
#include<conio.h>
int main()
{
int sp,prof;

printf("Enter the total selling price of the 15 items :


");
scanf("%d", &sp );//selling price

printf("\nEnter the total profit on these items : ");


scanf("%d", &prof );//profit

printf("\nCost price of a single item is %d.", (sp-


prof)/15);

getch();
return 0;
}

Que: Paper of size A0 has dimensions 1189 mm x 841 mm. Each subsequent size A(n) is
defined as A(n-1) cut in half parallel to its shorter sides. Write a program to calculate
and print paper sizes A0, A1, A2, ...A8.

#include<stdio.h>
#include<conio.h>

int main()
{
int A0_a, A0_b, A1_a, A1_b, A2_a, A2_b, A3_a, A3_b,
A4_a, A4_b, A5_a, A5_b, A6_a, A6_b, A7_a, A7_b, A8_a, A8_b;

A0_a = 1189;
A0_b = 841;
printf("\nA0 : %dmm x %dmm ", A0_a, A0_b);

A1_a = A0_b;
A1_b = A0_a/2;
printf("\nA1 : %dmm x %dmm ", A1_a, A1_b);

A2_a = A1_b;
A2_b = A1_a/2;
printf("\nA2 : %dmm x %dmm", A2_a, A2_b);

A3_a = A2_b;
A3_b = A2_a/2;
printf("\nA3 : %dmm x %dmm", A3_a, A3_b);

A4_a = A3_b;
A4_b = A3_a/2;
printf("\nA4 : %dmm x %dmm", A4_a, A4_b);

A5_a = A4_b;
A5_b = A4_a/2;
printf("\nA5 : %dmm x %dmm", A5_a, A5_b);

A6_a = A5_b;
A6_b = A5_a/2;
printf("\nA6 : %dmm x %dmm", A6_a, A6_b);

A7_a = A6_b;
A7_b = A6_a/2;
printf("\nA7 : %dmm x %dmm", A7_a, A7_b);

A8_a = A7_b;
A8_b = A7_a/2;
printf("\nA8 : %dmm x %dmm", A8_a, A8_b);

getch();
return 0;
}

Вам также может понравиться