Showing posts with label c programming. Show all posts
Showing posts with label c programming. Show all posts

program to accept a character in lowercase and convert it into uppercase

 /* write  a program to accept a character in lowercase and convert it into uppercase using  library function*/

#include<stdio.h>

#include<conio.h>

void main()

{            char ch;

              clrscr();

              printf(" \n Enter a character in lowercase :--");

              scanf("%c",&ch);

              ch=toupper(ch);

              printf(" \n  uppercase character = %c ",ch);

             getch();

}

/* output:--

                 Enter a character in lowercase :-- b

                 uppercase character  = B

*/

Algorithm of program

step 1: start

step 2: Declare ch

step 3: Accept character in lowercase

step 4: IS   ch=toupper(ch)

step 5:Display   uppercase character 

step 6:stop

                                                💬👇💗😊

Conditional and Ternary operator ( ?, : )

 Conditional and Ternary operator ( ?, : )

Conditional and Ternary operator is used to check the condition at that place of it by using this operator we can  minimize the length of the program because true part and false part of condition is written in a single line.

Syntax 

(condition )? true part : false part 

Conditional or Ternary Operator (?:) in C/C++ - GeeksforGeeks

Examples:--

/*Program to find the largest no among two number using conditional and ternary operator  */

#include<stdio.h>

#include<conio.h>

main()

{        int a,b;

          clrscr();

          printf(" \n Enter the value for a and b = \n");

          scanf("%d%d",&a,&b);

          (a>b)?printf("%d is largest ",a) : printf("%d is largest ",b);

         getch();

}


/*    Output:--

                    Enter the value for a and b =20

                                                                  10

                    20 is largest

*/

         

 flowchart :--


       

                                                        💬💭😀👇

/* 2. PROGRAM TO CALCULATE ARITHMETIC MEAN FOR DISCRETE SERIES*/

 /* 2. PROGRAM TO CALCULATE ARITHMETIC MEAN FOR DISCRETE SERIES*/

#include<stdio.h>

int main()

{

int x[]={1,2,3,4,5,6,7};

int f[]={5,9,12,17,14,10,6};

int i,xf[7],n=0;

float M,sf=0;

printf("\n COMPUTATION OF ARITHMETIC MEAN");

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

{

n=n+f[i];        /* Addition of Frequency */

xf[i]=x[i]*f[i]; /* Multiplication of X and Frequency */

sf=sf+xf[i];     /* Addition of X*Frequency */

}

printf("\n\n\tX\tFrequency\tFX\n\n");

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

printf("\n\t%d\t%d\t\t%d\n",x[i],f[i],xf[i]);

M=sf/n;

printf("\n Total Frequency: -%d",n);

printf("\n Total FX:- %f",sf);

printf("\n Arithmetic Mean Is:- %f",M);

return 0;

}









 

/* OUTPUT:-


 COMPUTATION OF ARITHMETIC MEAN


        X        Frequency       FX


        1                 5                5

        2                 9               18

        3                12              36

        4                17              68

        5                14              70

        6                10              60

        7                 6               42

 Total Frequency:- 73

 Total FX:- 299.000000

 Arithmetic Mean Is:- 4.095891    

*/

                                                                😊😉😦

/* 1 PROGRAM TO CALCULATE ARITHMETIC MEAN FOR INDIVIDUAL SERIES */


 /* 1 PROGRAM TO CALCULATE ARITHMETIC MEAN FOR INDIVIDUAL SERIES */

#include<stdio.h>

int main()

{

int i,n,x[10];

float sum=0,AM=0;

printf("Enter No. of observations:-\t");

scanf("%d",&n);

printf("Enter the values:-\t");

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

{

printf("\n");

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

sum=sum+x[i];

}

AM=sum/n;

printf("The Arithmetic Mean is:-\t");

printf("\n sum= %f",sum);

printf("\n AM=%f",AM);

return 0;

}

/* OUTPUT:-

Enter No. of observations : -      5

Enter the values:-

11

22

33

44

55

The Arithmetic Mean is:-

 sum= 165.000000

 AM=33.000000 */

                                                                        ðŸ˜ŠðŸ˜€ðŸ˜šðŸ‘€

                                                




                                                                     

syntax of c programming language







C language is developed by Dennis Ritchie.

Points to be remember while writing c program
1) every programming instruction must be returned within a main block.
2)All the instructions must be returned in a lowercase, because she is a case sensitive language it knows the difference between lowercase and uppercase.
3) every statement must be ended with a semicolon (;).
4)we May write constant variable or any user-defined thing in capital.


Steps to save ,compile and execute the program
1) save: File->save (F2) i.e first.c
2) compile and execute:Ctrol+F9
Note: if getch () is not there, then we can see the output screen using alt+F5, else directly we can see the output.
Example:

Syntax
Main ()
{           Clrscr();
             Printf("My first program in c.");
             getch ();
}
    Where
            Clrscr (): used to clear the screen.
            Printf ():  to display the text o value of variable on the                                                                     screen.
            getch ():  is used to hold output screen.                                    







Escape Sequences: is used to move the cursor on the particular position

'\n'(newline)           : is used to jump the cursor on the next line.
'\t'(tab)                   : to Move Cursor 5 characters along.
'\r'(carriage return):to move the cursor on the first character of the                                     current line.
'\b'(backspace)       : to jump the cursor one character left.







         

c program, Advance coding, c++ program, simple program, Advance language

online quiz Application project page MCA final year project

  Here we making a quiz application ppt presentation for college project so that our project idea will like to our professor and teacher  fi...