⌨️
‘C’ LANGUAGE PROGRAMMING 🖥
1. What is a Program?
A sequence of instructions to a computer is called as a program.
2. Who developed C Language?
C language was developed by Dennis Ritchie in 1972 in bell laboratories.
Before C language which language was used and by whom it was invented?
B language was in use and it was built by Ken Thompson.
3. Name some languages written using the ‘C’ language?
kernel, Oracle, Android
4. Who standardized the ‘C’ Language?
In 1989 the C language was standardized by Ansi[American National Standards Institute]
5. Say the difference between a Compiler and an Interpreter.
The compiler reads the whole source code and converts that code into machine code.
An interpreter reads every single line and converts that code into machine code.
6. What are the types of Language translators?
The are three types:
Assembler
Compiler
Interpreter
7. What is the 3-step process of a Compiler?
Translation ➡️Linking➡️Loading
‘C’ LANGUAGE PROGRAMMING 🖥 1
8. How many keywords are there in C?
There are 32 Keywords in C
9. What are the difference types of Sections in C?
1. Documentation Section
2. Link Section
3. Definition Section
4. Global Declaration Section
5. Main Section
6. Subject programming Section
10. How are the files are saved in C?( in order)
.c➡️.i➡️.obj➡️.exe
.c➡️.intermediate➡️.objective file➡️.executable file
11. What are the types of Constants in C?
Numeric Constant
Integer Constant
Floating/Real Constant
Character Constant
Single character Constant
String Constant
12. Define Single Character Constant.
A single character enclosed in a single quotation mark is called single character constant.
Eg: ‘A’
13. Define String Constant.
Characters enclosed in Double quotation is called String Constant.
Eg: ”Hello”
14. Abbreviate ascii values and write the values.
ascii= American Standard Code for Information Interchange.
‘C’ LANGUAGE PROGRAMMING 🖥 2
15. What is the difference between Keywords and Identifiers?
Keywords are already pre-defined words in C language which can’t be changed by
ourselves.
But Identifiers are user-defined words, they can be changed.
No special characters can’t be used in identifiers.
16. Why datatype is used in C?
Datatype is used to define the type of data that we gonna to store in a variable. So, only we
need datatypes.
17. What are the different types of Datatypes?
1. Primary Datatype
a. int
b. float
c. Double
d. char
e. void
2. Derived Datatype
a. Array
b. Structure
c. Union
d. Pointers
3. User-defined Datatype
a. Type defined
b. Enumerated Datatype
18. What is the format specifier for int?
%d
19. What is the format specifier for char?
%d
‘C’ LANGUAGE PROGRAMMING 🖥 3
20. What is the format specifier for float?
%f
21. What is the format specifier for Double?
%lf
21. What is an Expression in C?
Expression is a sequence of operators and operands which gives a single value after
processing.
Example: a= 5+5
a = variable
5,5= operands
+= operator
22. What are the types of Operator in C?
1. Unary operators
a. increment(++) and decrement operators
b. logical operator(!)
c. address of operator(&)
d. Size of
2. Binary Operators
a. Arithmetic operator(+,-,/,*,%)
b. Relational operator(<,>,≥,≤)
c. logical(&&, ||)
d. Bitwise operator(&,!,<<,>>,^)
e. Equality operator(==, ! =)
f. comma operator(,)
g. Assignment operator(=)
3. Tertiary operators
23. What is the work of %[Modulo] operator?
Modulo operator is used to give the reminder while dividing.
Modulo operator can be only used in integer datatype can’t be used in float.
24. Which operator has got the least priority?
|| logical or is got the least priority among operator next comes comma(,).
25. Why getch() is used in C?
getch() function is used to hold the output screen.
26. Why scanf() function is used in C?
It is used to get the input from the user during the time output.
‘C’ LANGUAGE PROGRAMMING 🖥 4
27. Say the difference between Formatted i/o and Unformatted i/o?
28. What are the different types of Control Statements in C?
if Statement
if-else statement
else-if ladder
Nested if
Switch
29. Why [;] is not used after if keyword?
If (;) is used after if Keyword it refers to the termination of the if keyword. So, we don’t use a
semicolon after if keyword.
30. Say some reasons why Switch is better than if-else statement and else-if ladder statement?
1. It is much simplified version of if-else statement and else-if ladder statement.
2. It executes faster.
3. It uses only switch, break, default, case only these four keywords.
31. What should be added after case keyword?
A colon(:) should be added after case Keyword.
31. Why Break Keyword is used in Switch statement?
Break is used to break the flow of execution in Switch statement.
32. Simple Output Calculator using switch case in c.
// Simple Output Calculator using switch case in c.
#include<stdio.h>
main()
{
‘C’ LANGUAGE PROGRAMMING 🖥 5
int a,b,sum,sub,mul,div;
char operator;
printf("Choose the operator:\n");
scanf("%c",& operator);
printf("Enter two operands:\n");
scanf("%d %d",&a,&b);
switch(operator)
{
case'+': sum= a+b;
printf("sum= %d\n",sum);
break;
case'-': sub= a-b;
printf("sub= %d\n",sub);
break;
case'*': mul= a*b;
printf("mul= %d\n",mul);
break;
case'/': div= a/b;
printf("div= %d\n",div);
break;
default:
printf("Enter valid operator\n");
}
getch();
}
33. WRITE A CODE FOR DISPLAYING THE ARRAY USING SCANF FUNCTION
//array program to display the array using scanf.
#include<stdio.h>
int main()
{
int i, a[5];
printf("Enter the elements of the array\n");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<5;i++)
{
printf("The elements are:%d\n",a[i]);
‘C’ LANGUAGE PROGRAMMING 🖥 6
}
}
34. WRITE A CODE TO DISPLAY THE ARRAY WITH INDEX USING SCANF FUNCTION
//array program to display the array using scanf with index in the output
#include<stdio.h>
int main()
{
int i, a[5];
printf("Enter the elements of the array\n");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<5;i++)
{
printf("The index of %d is:%d\n",i,a[i]);
}
}
35. WRITE A CODE TO DISPLAY THE ARRAY IN REVERSE ORDER
//array program to display the array using scanf with index in the output also in reverse order
#include<stdio.h>
int main()
{
int i, a[5];
printf("Enter the elements of the array\n");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
for(i=4;i>=0;i--)
{
printf("The index of %d is:%d\n",i,a[i]);
}
}
36. WRITE A PROGRAM TO ACCESS OR PRINT ONLY ONE ELEMENT FROM THE GIVEN ARRAY
//array program to access a particular data
#include<stdio.h>
int main()
{
int i, a[5];
printf("Enter the elements of the array\n");
for(i=0;i<5;i++)
‘C’ LANGUAGE PROGRAMMING 🖥 7
{
scanf("%d",&a[i]);
}
printf("The element is:%d\n",a[4]);
37. WRITE A PROGRAM TO READ 5 MARKS AND CALCULATE SUM AND AVERAGE USING
SCANF FUNCTION
//ARRAY PROGRAM TO READ 5 MARKS AND CALCULATE SUM AND AVERAGE
#include<stdio.h>
int main()
{
int marks[5],i;
int sum=0;
float avg;
printf("Enter the 5 marks\n");
for(i=0;i<5;i++)
{
scanf("%d",&marks[i]);
}
for(i=0;i<5;i++)
{
sum=sum+marks[i];
}
avg=sum/5;
printf("sum=%d\n",sum);
printf("avg=%f\n",avg);
}
38. WRITE A PROGRAM TO READ AN ARRAY OF 10 INTEGERS AND COUNT THE TOTAL
NUMBER OF EVEN AND ODD NUMBERS
/*PROGRAM TO READ AN ARRAY OF 10 INTEGERS AND COUNT THE TOTAL NUMBER OF EVE
#include<stdio.h>
int main()
{
int a[10],i;
int even=0;
int odd=0;
printf("Enter the elements to find the even and odd number\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
if(a[i]%2==0)
even++;
else
‘C’ LANGUAGE PROGRAMMING 🖥 8
odd++;
}
printf("The even numbers are:%d\n",even);
printf("The odd numbers are:%d\n",odd);
39. WRITE A PROGRAM TO ADD TWO ARRAY AND SAVE IT IN ANOTHER ARRAY
/*PROGRAM TO ADD TWO ARRAY AND SAVE IT IN ANOTHER ARRAY*/
#include<stdio.h>
int main()
{
int a[5], b[5],c[5],i;
printf("Enter the first array elements:\n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
printf("Enter the second array elements:\n");
for(i=0;i<5;i++)
scanf("%d",&b[i]);
for(i=0;i<5;i++)
{
c[i]=a[i]+b[i];
printf("The third elements at index %d is:%d\n",i,c[i]);
}
‘C’ PROGRAMS LEARNT THROUGHOUT THE 1-ST SEM
‘C’ LANGUAGE PROGRAMMING 🖥 9