Skip to main content

Posts

Showing posts from October, 2018

Write a C C++ program to swap values of two variable without using third variable

Flowchart


Coding in C

#include<stdio.h>
int main()
{
    int a,b;
    printf("Enter a b: ");
    scanf("%d%d",&a,&b);
    a = a+b;
    b = a-b;
    a = a-b;
    printf("a = %d b = %d",a,b);
    return 0;
}

Coding in C++
#include<iostream> using namespace std; int main() {     int a,b;     cout<<"Enter a b: ";     cin>>a>>b;     a = a+b;     b = a-b;     a = a-b;     cout<<"a = "<<a<<" b = "<<b;     return 0; }
Output

Write a C C++ program to find table of given number

Flowchart


Coding in C

#include<stdio.h>
int main()
{
    int num,c=1,res;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(c<=10)
    {
        res=num*c;
        printf("%d\n",res);
        c++;
    }
    return 0;
}

Coding in C++

#include<iostream>
using namespace std;
int main()
{
    int num,c=1,res;
    cout<<"Enter a number: ";
    cin>>num;
    while(c<=10)
    {
        res=num*c;
        cout<<res<<"\n";
        c++;
    }
    return 0;
}

Output