Programming

Function Passing No Arguments and Returning no Value

  • January 24, 2021
  • 0 Comments

Write a program to functions to passing no arguments an returning no values. #include <stdio.h>#include <conio.h>void sum (void);void main(){ sum(); getch();}void sum(void){ int add, a, b; printf(“Enter two numbers:”); scanf(“%d%d”,&a,&b); add=a+b; printf(“n the sum is %d”,add);} Output

Function Passing no Arguments and Returning Values Programming

Function Passing No Arguments and Returning Values

  • January 24, 2021
  • 0 Comments

This program describes how to write function passing no arguments and returning values. #include <stdio.h>#include <conio.h>int sum (void);void main(){ int c; c=sum(); printf(“n The sum of two numbers is : %d”,c); getch();}int sum(void){ int add, a, b; printf(“Enter two numbers:”); scanf(“%d%d”,&a,&b); add=a+b; return(add);} Output

Programming

Function Passing Arguments and Returning No Value

  • January 24, 2021
  • 0 Comments

This C program describes how to write a code for function passing arguments and returning no value. #include <stdio.h>#include <conio.h>void sum (int, int);void main(){ int a,b; printf(“enter two numbers :”); scanf(“%d%d”,&a,&b); sum(a,b); getch();}void sum(int s, int t){ int add; add = s+t; printf(“n The sum of the two numbers is : %d”, add); } Output

Programming

C – Find Sum of N Integer Numbers Using the Function

  • January 24, 2021
  • 0 Comments

Write a c program to find the sum of the N integer numbers using the fuctions. #include <stdio.h>#include <conio.h>int sum (int number);void main(){ int n; printf(“How many number : “); scanf(“%d”, &n); printf(“sum the %d numbers is : %d “,n,sum(n)); getch();}int sum(int number){ int i, add=0; for(i=1; i<=number; i++){ add+=i; } return add;} Output

Programming

C – Find Prime Number from 1 to 100 Using the Function

  • January 24, 2021
  • 0 Comments

Find prime number from 1 to 100 numbers using the function on C program. #include <stdio.h>#include <conio.h>int primenumber (int number);void main(){ int i; printf(“given numbers are prime numbers :n”); for(i =1; i<=100; i++) { if(primenumber(i)) printf(“%dt”,i); } getch();}int primenumber(int number){ int i, flag=1; for(i=2; i<=number/2; i++){ if(number%i==0) flag = 0; } return flag;} Output

Function Passing Arguments and Returning Value Programming

Function Passing Arguments and Returning Value

  • January 24, 2021
  • 0 Comments

This program describes that function passing arguments and returning value. #include <stdio.h>#include <conio.h>int sum (int, int);void main(){ int a,b,c; printf(“enter two numbers :”); scanf(“%d%d”,&a,&b); c = sum(a,b); printf(“n the sum of two numbers is : %d”, c); getch();}int sum(int s, int t){ int add; add = s+t; return (add); } Output

Programming

C – Find the Factorial of Entered Number using Recursive Function

  • January 24, 2021
  • 0 Comments

This program explains how to find factorial of the entered number using recursive function. #include <stdio.h> #include <conio.h> int factorial (int); void main() { int number; printf(“enter a numbers :”); scanf(“%d”,&number); printf(“n the factorial of the entered number %d is : %d”,number, factorial(number)); getch(); } int factorial(int number){ if (number<=1) return(1); else return(number*factorial(number-1)); } Output

Programming

C – Check Entered Number is Exactly Divisible by 5 but not 11

  • January 24, 2021
  • 0 Comments

Write a program that checks whether the number entered by the user is exactly divisible by 5 but not by 11.  C Code #include <stdio.h>#include <conio.h>#include <math.h>void main(){ int number; printf(“enter number:”); scanf(“%d”, &number); if(number%5==0 && number%11!=0) printf(“%d is divisible by 5 but not by 11”, number); else printf(“condition is not satisfied”); getch();} Output

Programming

C – Find the Square Root Number Using the Function

  • January 24, 2021
  • 0 Comments

Write a c program to find the square root of the number.  #include<stdio.h>#include<conio.h>#include<math.h>void main(){ int num; int squreroot(int num); printf(“Input Number:”); scanf(“%d”,&num); squreroot(num); getch();}int squreroot(int num){ printf(“squreroot: %f”,sqrt(num)); return 0; }

Program to convert decimal to binary Programming

C Program to Convert Decimal to Binary

  • January 24, 2021
  • 0 Comments

Write a c program to convert decimal number to binary number. /*Program to convert decimal to binary*/#include<stdio.h>#include<conio.h>int bin(int x);void main(){ int x,binary; printf(“Enter Decimal Number:”); scanf(“%d”,&x); binary=bin(x); printf(“The Binary number is %d”,binary);getch();}int bin(int x){ int q,r; if(x==0) return; q=x/2; r=x%2; bin(q); printf(“%d”,r);}