Tuesday, July 28, 2020

Solving your first problem in C++ on CodeChef

Problem Name : Life, the Universe, and Everything

How to solve this question?


In this question they telling us to take the input of a number and display that number, repeat this proedure till we encounter number 42. After that we need to stop.

Solution :


#include <iostream>
using namespace std;

int main() {
// your code goes here
int number;
cin>>number;
while(number!=42)
{
    cout<<number<<endl;
    cin>>number;
}
return 0;
}




Sunday, July 26, 2020

Introduction to Programming in C week 0 assignment(jul-dec 2020)

Hello everyone! solution of Introduction to Programming in C week 0 assignment are given below.

Question 1 : 


#include<stdio.h>

int main()
{
  printf("Hello C");
  return 0;
}

Question 2 :


#include<stdio.h>

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  int avg = (a+b)/2;
  printf("%d",avg);
  return 0;
}