Solution of Old is gold of computer|grade 12|Programming in C|2074 supp

Solution of Old is gold of computer|grade 12|Programming in C|2074 supp

 

2074 supp. Q. No. 1

a.      What is control structure in C? Describe if – else statement with example.

What is control structure in C?

Describe if-else statement with example.

Click here

2074 supp. Q. No. 2

b.     What are different types of loop in C? Write a program to print multiplication table of 1 to 10

Types of loop are

for loop:-Click here

while loop:-Click here

do while loop:-Click here

 Write a program to print a multiplication table of 1 to 10

Click here

 2074 supp. Q. No. 3

Write a C program to input any 10-integer number in an array and find the total.

#include<stdio.h>

#include<conio.h>

void main()

{

          int num[10], i, j, s=0;

          printf("\n Enter 10 integers");

          for(i=0;i<10;i++)

          {

                   scanf("%d", &num[i]);

          }

          for(i=0;i<10;i++)

          {

                   s=s+num[i];

          }

          printf("\n Total=%d",s);

          getch();

}

Output



2074 supp. Q. No. 4

What are string function in C? Write a program to print the given text in reverse order.

String function in C

 C program allows multiple library or built-in function for string manipulation which are defined under #include<string.h>. some string function are

strlen():- This function takes a string as a parameter and return the integer value as the length of string contain all the character.

Syntax of strlen()

int variable=strlen(string);

strcpy():- The function strcpy() is use to copy one string to another string. It takes two string as a parameter and copy characters of source string to destination string.

Syntax of strcpy()

strcpy(destination string, source string);

strcat():- This function is used to concatenate i.e. it appends a string to the end of next string. This function takes two string as a parameter and copy character by character of the second string to the end of first string.

syntax of strcat()

strcat(string1,string2);

strrev():- strrev() function is use to reverse all the character. It takes one string as a parameter and reverse all the character of a string except null character.

Syntax of strrev()

strrev(string);

strupr():- This function strupr() takes a string as a parameter and convert all alphabets of a string into capital letters.

Syntax of strupr()

strupr(string);

strlwr():- This function strlwr() takes a string as a parameter and convert all alphabets of a string into small letters.

Syntax of strlwr()

strlwr (string);

strcmp():- This function takes two string as a parameter and compares to each other. It returns an integer where the value is

(i)                  >0 -------- if first string is greater than second string

(ii)                <0---------If first sting is less than second string

(iii)               =0---------if both string are equal

Syntax of strcmp()

int variable = strcmp(string1, string2);

Write a program to print the given text in reverse order.

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

                char string1[20];

                printf("\n Enter a string");

                scanf("%s",string1);

                strrev(string1);

                printf("\n Reverse string=%s", string1);

                getch();

}

Output

2074 supp. Q. No. 5

Describe the structure in C. Write a C program to enter the 5 subject marks and calculate sum and print using structure.

Describe the structure in C.

Click here

Write a C program to enter the 5 subject marks and calculate sum and print using structure.

#include<stdio.h>

#include<conio.h>

void main()

{

          struct record

          {

            int mark;   

          };

          struct record a[5];

          int i, s=0;

          printf("\n Enter marks of 5 students");

          for(i=0;i<=5;i++)

          {

                   scanf("%d", &a[i].mark);

          }

          for(i=0;i<=5;i++)

          {

                   s = s + a[i]. mark;

          }

          printf("\n Sum of 5 subjects = %d", s);

}

Output



 

 

 

 

Post a Comment

0 Comments