2074 Set B Q. n. no 1
a. What is a switch case statement in C Program? Explain with examples.
b. Explain For loop in C with examples
2074 Set B Q. n. no 2
Describe the syntax of array. Write a program to sort ten integer numbers in ascending order.
Describe the syntax of array.
Syntax of array
data_type variable[size];
Write a program to sort ten integer numbers in ascending order.
#include<stdio.h>
#include<conio.h>
void main()
{
int num[10], i, j, temp;
printf("\n Enter 10 integers");
for(i=0;i<10;i++)
{
scanf("%d", &num[i]);
}
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
{
if(num[i]>num[j])
{
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
}
printf("\n Printing in ascending order");
for(i=0;i<10;i++)
{
printf("\n %d", num[i]);
}
getch();
}
Output
2074 Set B Q. n. no 3
What is the method of function declaration and call in C? Write a Program to find out given number is odd or even using function
What are the method of function declaration and call in C?
Write a Program to find out given number is odd or even using function
#include<stdio.h>
#include<conio.h>
void evenodd(int);
void main()
{
int n;
printf("\n Enter a number");
scanf("%d", &n);
evenodd(n);
getch();
}
void evenodd(int n)
{
if(n%2==0)
{
printf("\n %d is even number", n);
}
else
{
printf("\n %d is odd number", n);
}
}
Output
2074 Set B Q. n. no 4
What is string? Explain any four-string function with examples
What is string?
Explain any four-string function with examples
2074 Set B Q. n. no 5
What is structure in C? Write a program to enter the 20 employees’ name, age and salary using structure and print them
What is structure in C?
Write a program to enter the 20 employees’ name, age and salary using structure and print them
#include<stdio.h>
#include<conio.h>
void main()
{
struct record
{
int age, sal;
char name[20];
};
struct record a[20];
int i;
printf("\n Enter Name age and salary of 20 employees");
for(i=0;i<20;i++)
{
scanf("%c%d%d", a[i].name, &a[i].age, &a[i].sal);
}
for(i=0;i<20;i++)
{
printf("\n Name=%c\tAge=%d\tSalary=%d", a[i].name, a[i].age, a[i].sal);
}
getch();
}
Output



0 Comments
Please do not enter any spam link on comment box