C program for the addition of N natural numbers using if else statements
kw.c
Output
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program for the addition of N numbers ——————————————————————————————————————————— Enter the number 0 Please enter the positive natural number ——————————————————————————————————————————— kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program for the addition of N numbers ——————————————————————————————————————————— Enter the number 10 Sum of 10 natural numbers = 55 ——————————————————————————————————————————— kodingwindow@kw:~$
C program for the addition of N natural numbers using while loop
kw.c
Output
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program for the addition of N numbers ——————————————————————————————————————————— Enter the numbers -10 -50 10 30 0 Sum = -20.000000 ——————————————————————————————————————————— kodingwindow@kw:~$
What Next?
C program to convert a binary number to an equivalent decimal number
C program to demonstrate the static and local variables
Find the output of C programs
Advertisement