Author Topic: Programming Challenge!!!!  (Read 57188 times)

0 Members and 1 Guest are viewing this topic.

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #15 on: January 12, 2010, 11:32:08 pm »
Quote from: jaini on January 12, 2010, 08:36:59 pm
//wap to multiply  two no with out using "*" operator




#include<iostream>

using namespace std;

int  main()
{
    int x,y,z=0;
    cin>>x>>y;

    for(int i=1;i<=y;i++)
        z+=x;
    cout<<z<<endl;
    return 0;
}





this one is write.

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #16 on: January 12, 2010, 11:40:07 pm »
this programe is on net or not i dont know because this programe is just asked by my frnd i.e slimshady on this forum.
i have posted  it because i think it can be useful.
wap to find a no even or odd with out using no "2 and 0" in c or c++?

« Last Edit: January 13, 2010, 07:33:21 pm by techmaniac »

Offline jaini

  • Member
  • Newbie
  • *
  • Points: 0
  • Posts: 8
    • View Profile
Programming Challenge!!!!
« Reply #17 on: January 14, 2010, 10:33:37 pm »
//wap to find a no even or odd with out using no "2 and 0" in c or c++?



#include<iostream>

using namespace std;

int main()
{
   int x,y;
   cin>>x; y=x;
   x++; x++;
   if( !(x%4 && y%4))
      cout<<"even"<<endl;
   else cout<<"odd"<<endl;
   return 1;
}

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #18 on: January 14, 2010, 10:53:26 pm »
Quote from: jaini on January 14, 2010, 10:33:37 pm
//wap to find a no even or odd with out using no "2 and 0" in c or c++?



#include<iostream>

using namespace std;

int main()
{
   int x,y;
   cin>>x; y=x;
   x++; x++;
   if( !(x%4 && y%4))
      cout<<"even"<<endl;
   else cout<<"odd"<<endl;
   return 1;
}


this one is also write

but much easier is which i have solved in 2 min.

#include<iostream>

using namespace std;

void main()
{
   int x,y;
   cin>>x;
        y=x^2;
   
   if(y%4)
      cout<<"odd"<<endl;
   else
                cout<<"even"<<endl;

}


logic: if you square any even no then modulas of this square no with 4 is always =0

and it multiples when you find cube of any even number then modulus of that cube with 8 is always =0

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #19 on: January 14, 2010, 11:06:56 pm »
wap to print "hello world" without using semicolon in c or c++?

i am waiting for your answers give answer in two dayz otherwise i will tell you.
« Last Edit: January 14, 2010, 11:18:27 pm by techmaniac »

Offline Tj015

  • Member
  • Newbie
  • *
  • Points: 0
  • Posts: 1
    • View Profile
Programming Challenge!!!!
« Reply #20 on: January 15, 2010, 10:28:39 am »
#include<iostream.h>
#include<conio.h>
void main()
{
if(cout<<"hello world")
}

Offline rudeman

  • Just live the way you want....
  • Administrator
  • Techbits Elite Member
  • *
  • Points: 725
  • Posts: 2321
  • Just live the way you want....

    • MAIT
    • _
      Not Specified
    • View Profile
    • http://www.ridely.co
Programming Challenge!!!!
« Reply #21 on: January 15, 2010, 03:23:44 pm »
Quote from: techmaniac on January 14, 2010, 11:06:56 pm
wap to print "hello world" without using semicolon in c or c++?

i am waiting for your answers give answer in two dayz otherwise i will tell you.


This question must be asked by VKS sir .
am i right ?????

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #22 on: January 15, 2010, 05:52:41 pm »
Quote from: rudeman on January 15, 2010, 03:23:44 pm
Quote from: techmaniac on January 14, 2010, 11:06:56 pm
wap to print "hello world" without using semicolon in c or c++?

i am waiting for your answers give answer in two dayz otherwise i will tell you.


This question must be asked by VKS sir .
am i right ?????


no sir

it came in ipu previous year papers.[i think sec sem sub:ITP]

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #23 on: January 15, 2010, 05:53:17 pm »
Quote from: Tj015 on January 15, 2010, 10:28:39 am
#include<iostream.h>
#include<conio.h>
void main()
{
if(cout<<"hello world")
}


answer is correct

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #24 on: January 15, 2010, 06:03:57 pm »
wap to convert string into integer in c or c++?

Offline slimshady

  • there is a slimshady in all of us..
  • Member
  • Sr. Member
  • *
  • Points: 15
  • Posts: 474
  • there is a slimshady in all of us..
    • View Profile
Programming Challenge!!!!
« Reply #25 on: January 15, 2010, 11:37:09 pm »
Quote from: techmaniac on January 15, 2010, 05:53:17 pm
Quote from: Tj015 on January 15, 2010, 10:28:39 am
#include<iostream.h>
#include<conio.h>
void main()
{
if(cout<<"hello world")
}


answer is correct


waise ,is prog. me kya logic lagaya h,anybody plz explain...... :think :at wits end  
« Last Edit: January 15, 2010, 11:42:20 pm by slimshady »

Offline freaking

  • Member
  • Newbie
  • *
  • Points: 0
  • Posts: 16
    • View Profile
Programming Challenge!!!!
« Reply #26 on: January 16, 2010, 11:46:00 am »
Quote from: techmaniac on January 15, 2010, 06:03:57 pm
wap to convert string into integer in c or c++?


Are you askin to convert a char into its integer form that is its ascii number or a word/string into integer equivalent.

if it is to convert a char into its integer form then it is simple and is:

#include<iostream.h>
#include<conio.h>
void main()
{
   clrscr();
   char a;
   int b;
   cout<<"Enter a letter  ";
   cin>>a;
   b=a;
   cout<<"\\nAscii number of above letter is "<<b;
   getch();

}
Enjoy every second of your life   :hd

Offline freaking

  • Member
  • Newbie
  • *
  • Points: 0
  • Posts: 16
    • View Profile
Programming Challenge!!!!
« Reply #27 on: January 16, 2010, 11:53:45 am »
Here's my ques
WAP to convert a number into its binary equivalent
1) using array
2) without using array
Enjoy every second of your life   :hd

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #28 on: January 16, 2010, 12:10:53 pm »
Quote from: freaking on January 16, 2010, 11:46:00 am
Quote from: techmaniac on January 15, 2010, 06:03:57 pm
wap to convert string into integer in c or c++?


Are you askin to convert a char into its integer form that is its ascii number or a word/string into integer equivalent.

if it is to convert a char into its integer form then it is simple and is:

#include<iostream.h>
#include<conio.h>
void main()
{
   clrscr();
   char a;
   int b;
   cout<<"Enter a letter  ";
   cin>>a;
   b=a;
   cout<<"\\nAscii number of above letter is "<<b;
   getch();

}

this one is also write but i want to convert string numbers into integer

#include<iostream>
void main(0
{
 char str[]="567.3";
int a;
a=atoi(str);
cout<<"integer number is"<<a;
getch();
}

Offline techmaniac

  • kar bhla to ho bhla
  • Alumni
  • Techbits Elite Member
  • *
  • Points: 340
  • Posts: 2845
  • kar bhla to ho bhla
    • _
      Not Specified
    • View Profile
Programming Challenge!!!!
« Reply #29 on: January 16, 2010, 12:40:46 pm »
Quote from: freaking on January 16, 2010, 11:53:45 am
Here's my ques
WAP to convert a number into its binary equivalent
1) using array
2) without using array


i have made  this using array is

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{ clrscr();
int a,j,k,b[60];
cout<<"enter a  no";
cin>>a;
j=k=0;
while(a>1)
{
  b[j]=a%2;
  a=a/2;
  if(a==1)
  { j=j+1;
  b[j]=a;
}
  j++;
  k++;
  }
for(int i=k;i>=0;i--)
{
cout<<b;
}
getch();
 }

 

DIRECT X game programming

Started by sarthak9333

Replies: 1
Views: 1357
Last post December 05, 2012, 03:06:32 pm
by SagarDabas
improve your programming...!!!

Started by ab2757

Replies: 14
Views: 5736
Last post August 27, 2013, 08:14:34 pm
by cool98765
programming is frustrating!!

Started by slimshady

Replies: 6
Views: 2989
Last post January 22, 2010, 08:11:14 pm
by ANKITSINGHAL
regarding java programming

Started by Ratika

Replies: 4
Views: 2721
Last post May 14, 2015, 07:17:38 pm
by sagrma
C programming problems

Started by RAYAN FOSTER

Replies: 16
Views: 4132
Last post July 26, 2015, 05:53:38 pm
by Dar3deviL
Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49